<#include "/common/layout.html"> 
<@body>
<div class="content">
	<form class="form-horizontal" method="post" action="${request.contextPath}/system/sysJob/doEdit" id="editJobForm">
		<div class="box-body">
			<div class="form-group">
				<label class="col-sm-2 control-label">任务名称</label>
				<input type="hidden" value="${sysJob.jobId}" name="jobId">
				<div class="col-sm-10">
					<input type="text" id="jobName" name="jobName" value="${(sysJob.jobName)!}" class="form-control" placeholder="请输入任务名称" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">任务分组</label>
				<div class="col-sm-10">
					<select name="jobGroup" class="form-control select2" style="width: 100%;" required>
						<option value="DEFAULT" ${(sysJob.jobGroup == 'DEFAULT')?string('selected','')}>默认</option>
						<option value="SYSTEM" ${(sysJob.jobGroup == 'SYSTEM')?string('selected','')}>系统</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">调用目标字符串</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" id="invokeTarget" name="invokeTarget" value="${(sysJob.invokeTarget)!}" placeholder="请输入调用目标" required>
					<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例：jobTaskTest.jobNoParams()</span>
	   				<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例：com.qingshop.mall.modules.job.task.cancelOrder.cancel('取消操作')</span>
	   				<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明：支持字符串，布尔类型，长整型，浮点型，整型</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">cron表达式</label>
				<div class="col-sm-6">
					<input type="text" class="form-control" id="cronExpression" value="${(sysJob.cronExpression)!}" name="cronExpression" placeholder="请输入cron表达式" required>
				</div>
				<label class="col-sm-4" style="padding:7px 0px;">
					<a herf="javascript:;" onclick="openCron()"><i class="fa fa-fw fa-question-circle"></i>cron表达式</a>
				</label>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">执行策略</label>
				<div class="col-sm-10">
					<label class="radio-box"><input type="radio" class="minimal" name="misfirePolicy" value="1" ${(sysJob.misfirePolicy == 1)?string('checked','')}/> 立即执行 </label> 
					<label class="radio-box"><input type="radio" class="minimal" name="misfirePolicy" value="2" ${(sysJob.misfirePolicy == 2)?string('checked','')}/> 执行一次 </label> 
					<label class="radio-box"><input type="radio" class="minimal" name="misfirePolicy" value="3" ${(sysJob.misfirePolicy == 3)?string('checked','')}/> 放弃执行 </label>
					<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 立刻执行：重做错过的所有频率周期后</span>
	   				<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 执行一次：以当前时间为触发频率立刻触发一次执行</span>
	   				<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 放弃执行：不触发立即执行</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">并发执行</label>
				<div class="col-sm-10">
					<label class="radio-box"><input type="radio" class="minimal" name="concurrent" value="0" ${(sysJob.concurrent == 0)?string('checked','')} /> 允许 </label> 
					<label class="radio-box"><input type="radio" class="minimal" name="concurrent" value="1" ${(sysJob.concurrent == 1)?string('checked','')} /> 禁止 </label> 
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">状态</label>
				<div class="col-sm-10">
					<label class="radio-box"><input type="radio" class="minimal" name="status" value="0" ${(sysJob.status == 0)?string('checked','')} /> 正常 </label> 
					<label class="radio-box"><input type="radio" class="minimal" name="status" value="1" ${(sysJob.status == 1)?string('checked','')} /> 暂停 </label> 
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">备注</label>
				<div class="col-sm-10">
					<input type="text" id="remark" name="remark" value="${(sysJob.remark)!}" class="form-control" placeholder="请输入备注" required>
				</div>
			</div>
		</div>
	</form>
</div>
</@body>

<script type="text/javascript">
	/* 查看cron表达式 */
	function openCron(){
		parent.layer.open({
			type : 2,
			title : 'cron表达式',
			closeBtn : 1,
			anim: -1,
			isOutAnim: false,
			shadeClose : true,
			shade : 0.3,
			area : ['100%', '100%'],
			btn : ['取消'],
			content : '/tocron',
			success: function(layero, index){
			}
		});
	}
	function submitHandler() {
		if ($("#editJobForm").validate().form()) {
			var formData = $("#editJobForm").serialize();
			var index = layer.load(3); // 换了种风格
			$.ajax({
				url : $("#editJobForm").attr('action'),
				type : 'POST',
				data : formData,
				beforeSend : function() {
					$.modal.loading("正在处理中，请稍后...");
					$.modal.disable();
				},
				success : function(data) {
					layer.close(index);
					if (data.code == 200) {
						if (data.msg) {
							parent.layer.msg(data.msg, {
								icon : 1
							});
						} else {
							parent.layer.msg('提交成功', {
								icon : 1
							});
						}
						parent.layer.closeAll('iframe'); // 关闭当前frame
						window.parent.data_oTable.draw(false);
					} else {
						layer.msg(data.msg, {
							icon : 2
						});
						$.modal.closeLoading();
						$.modal.enable();
					}
				}
			});
		}
	}
</script>
